<!--
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-06-11 14:15:55
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-11 20:57:17
 * @FilePath: \vue3_admin_template\project\src\views\screen\component\Age\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="box2">
    <p class="title">年龄比例</p>
    <p class="bg"></p>
    <!-- 饼图 -->
    <div class="echart" ref="echart"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
//获取图形图表的DOM节点
let echart = ref()
onMounted(() => {
  //初始化Echarts实例
  let myEcharts = echarts.init(echart.value)
  myEcharts.setOption({
    tooltip: {
      trigger: 'item',
    },

    legend: {
      top: '25%',
      right: '10%',
      orient: 'vertial', //  cc垂直 图例的显示方向 默认是水平
      textStyle: {
        color: '#fff',
        fontSize: 18,
      },
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: ['40%', '70%'],
        center: ['30%', '55%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2,
        },
        label: {
          show: true,
          position: 'inside',
          color: '#fff',
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 10,
            fontWeight: 'bold',
          },
        },
        labelLine: {
          show: false,
        },
        data: [
          { value: 1048, name: '新闻' },
          { value: 735, name: '军事' },
          { value: 580, name: '体育' },
          { value: 300, name: '地理' },
        ],
      },
    ],
    grid: {
      top: 0,
      bottom: 0,
      left: 0,
      right: 0,
    },
  })
})
</script>

<style lang="scss" scoped>
.box2 {
  margin: 10px 0px 0 0;
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    color: #fff;
    font-size: 20px;
    margin-left: 20px;
  }
  .bg {
    width: 68px;
    height: 7px;
    background: url('../../images/dataScreen-title.png') no-repeat;
    background-size: cover;
    margin: 10px 0 0 20px;
  }
  .echart {
    width: 100%;
    height: 260px;
    // background-color: red;
  }
}
</style>
